package com.qys.livesMall.shop.mapper;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qys.livesMall.shop.modal.dto.ShopProductAnchorOrderInfoDto;
import com.qys.livesMall.shop.modal.entity.ShopOrderSku;
import com.qys.livesMall.shop.modal.entity.ShopStatisticsEveryDay;
import com.qys.livesMall.shop.modal.vo.OrderAnchorListVO;
import com.qys.livesMall.shop.modal.vo.OrderFansRepurchaseVO;
import com.qys.livesMall.shop.modal.vo.ShopDailyDataVO;
import com.qys.livesMall.shop.modal.vo.ShopOrderSkuVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author gmx
 * @since 2023-06-19
 */
@Mapper
public interface ShopOrderSkuMapper extends BaseMapper<ShopOrderSku> {
    @Select("select count(*) from " +
            "h2_shop_order_info as a " +
            "join h2_shop_order_sku as b " +
            "on a.id = b.order_id " +
            "where b.shop_id=#{shopId} and a.is_delete=0 and b.settlement_status = 0 ")
    Long countOrderSkusByShopId(@Param("shopId") Long shopId);
    List<OrderAnchorListVO> getOrderAnchorList(DateTime yesterday);

    Page<ShopOrderSkuVO> listProductAnchorOrder(@Param("page") Page<ShopOrderSkuVO> page,
                                                @Param("dto") ShopProductAnchorOrderInfoDto dto);

    ShopOrderSkuVO getProductAnchorInfo(String skuId);

    List<OrderFansRepurchaseVO> getFansRepurchase();

    /**
     *
     * @param time
     * @param type 小店类型（1：正常店铺 2：水军店铺）
     * @return
     */
    ShopDailyDataVO getShopOrderData(@Param("time") String time,@Param("type") Integer type);

    Map<String,String> getUserOrderInfo(@Param("orderNo") String orderNo);

    Integer getOrderNum(@Param("shopId") Long shopId,@Param("startTime")LocalDateTime startTime,@Param("endTime")LocalDateTime endTime);

    List<ShopStatisticsEveryDay> getEveryDayOrderNum(@Param("shopId") Long shopId);
}
